import frontend.ErrorList;
import frontend.Lexer;
import frontend.Parser;


import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

public class Compiler {

    public static Lexer lexer = Lexer.getInstance();
    public static Parser parser = Parser.getInstance();
    public static final ErrorList errorlist = ErrorList.getInstance();

    public static void main(String[] args) {
        String currentDir = System.getProperty("user.dir");
        System.out.println("当前工作目录: " + currentDir);
        String filePath = "testfile.txt";
        try {
            // 读取文件所有行并存入List中
            List<String> lines = Files.readAllLines(Paths.get(filePath));
            lexer.getTokens(lines);
        } catch (StringIndexOutOfBoundsException |IOException e) {
            e.printStackTrace();
        }
        //lexer.outputWord();

        parser.startParse(lexer.getToken());
        parser.output();
        errorlist.outputAll();
    }

}
